home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: nntp.coast.net!torn!sq!msb
- From: msb@sq.com (Mark Brader)
- Subject: Re: printing pid_t...
- Message-ID: <1996Feb21.003616.13884@sq.com>
- Organization: SoftQuad Inc., Toronto, Canada
- References: <4gcv6f$6jf@cisunix1.dfci.harvard.edu>
- Date: Wed, 21 Feb 1996 00:36:16 GMT
-
- Godfrey Degamo (gotd@jimmy.harvard.edu) writes:
- > Anyways, I want to read and write pid_t to a text file. The problem
- > is how is pid_t type defined? As an int, long, unsigned int or
- > unsigned long. (I think that's all the types that pid_t can be...)
- > Can I be safe to assume unsigned long and use %lu for printing and
- > scanning?
-
- If you want to print a value of unknown integral type, you have to know
- whether or not it's a signed type (or at least whether or not the value
- could be negative). Then *convert* to long or unsigned long as desired,
- and print that. Thus: printf ("My PID = %lu\n", (unsigned long) my_pid);
-
- --
- Mark Brader, msb@sq.com, SoftQuad Inc., Toronto
- #define MSB(type) (~(((unsigned type)-1)>>1))
-
- My text in this article is in the public domain.
-